import tkinter as tk
from functools import partial

from drawHG import draw_bar_chart
from drawPC import draw_pie_chart
from drawRC import switch_to_draw_RC


def switch_to_draw(window):
    window.withdraw()  # 隐藏当前窗口
    draw_window = tk.Toplevel()  # 创建新窗口
    draw_window.title("画图")  # 界面标题
    draw_window.geometry("400x500")  # 窗口大小

    # 在这里添加新的按钮和逻辑
    # 跳转回归曲线页面按钮
    regression_curve_button = tk.Button(draw_window, text="回归曲线", font=("Helvetica", 12), height=3, width=6)
    regression_curve_button.configure(command=partial(switch_to_draw_RC, draw_window))
    regression_curve_button.pack()

    # 添加饼状图按钮
    pie_chart_button = tk.Button(draw_window, text="饼状图", font=("Helvetica", 12), height=3, width=6)
    pie_chart_button.configure(command=partial(draw_pie_chart, draw_window))
    pie_chart_button.pack()

    # 添加柱状图按钮
    regression_histogram_button = tk.Button(draw_window, text="柱状图", font=("Helvetica", 12), height=3, width=6)
    regression_histogram_button.configure(command=partial(draw_bar_chart, draw_window))
    regression_histogram_button.pack()
    # 添加返回按钮，返回到原始计算器
    return_button = tk.Button(draw_window, text="返回",
                              command=lambda: [draw_window.destroy(), window.deiconify()])
    return_button.pack()
